package com.fyy.controller;

import com.fyy.model.User;
import com.fyy.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @Author fyy
 * @Description
 * @Date 2020/6/1 10:42
 */
@RestController
public class UserController {

    @Qualifier(value = "userService")
    @Autowired
    private IUserService userService = null;

    @RequestMapping("/con/user/{id}")
    public User getser(@PathVariable("id") long id){
         return this.userService.queryUserById(id);
    }

    @RequestMapping("/con/user/save")
    public boolean saveUser(String username,String pass){
        User u = new User();
        u.setUsername(username).setPass(pass);
        return this.userService.addUser(u);
    }

    @RequestMapping("/query")
    public List<User> queryAllUser(){
        return this.userService.queryUserList();
    }



}
